﻿using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Reflection;
using Gammar.Digger.SystemFramework;
using Gammar.Digger.Entity;
using Gammar.Digger.IDAL;
using Gammar.Digger.Data;
namespace Gammar.Digger.DALSqlServer
{
    public partial class digger_sourceData
    {
        public int Add(digger_sourceDataEntity entity, string tableName)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(string.Format("INSERT INTO {0}(",tableName));
            strSql.Append("data_id,title,detail,original_price,sale_price,image,create_time,source_name,image_path,last_modify_time,brand,url_id)");
            strSql.Append(" VALUES (");
            strSql.Append("@data_id,@title,@detail,@original_price,@sale_price,@image,@create_time,@source_name,@image_path,@last_modify_time,@brand,@url_id)");
            SqlParameter[] parameters = {
					new SqlParameter("@data_id",SqlDbType.UniqueIdentifier),
					new SqlParameter("@title",SqlDbType.VarChar),
					new SqlParameter("@detail",SqlDbType.Text),
					new SqlParameter("@original_price",SqlDbType.VarChar),
					new SqlParameter("@sale_price",SqlDbType.VarChar),
					new SqlParameter("@image",SqlDbType.VarChar),
					new SqlParameter("@create_time",SqlDbType.VarChar),
					new SqlParameter("@source_name",SqlDbType.VarChar),
					new SqlParameter("@image_path",SqlDbType.VarChar),
					new SqlParameter("@last_modify_time",SqlDbType.BigInt),
					new SqlParameter("@brand",SqlDbType.VarChar),
					new SqlParameter("@url_id",SqlDbType.UniqueIdentifier)
					};
            parameters[0].Value = entity.data_id;
            parameters[1].Value = entity.title;
            parameters[2].Value = entity.detail;
            parameters[3].Value = entity.original_price;
            parameters[4].Value = entity.sale_price;
            parameters[5].Value = entity.image;
            parameters[6].Value = entity.create_time;
            parameters[7].Value = entity.source_name;
            parameters[8].Value = entity.image_path;
            parameters[9].Value = entity.last_modify_time;
            parameters[10].Value = entity.brand;
            parameters[11].Value = entity.url_id;

            return helper.ExecuteNonQuery(strSql.ToString(), parameters);
        }
    }
}
